package com.hnevc.yourhealthmanager.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnevc.yourhealthmanager.entity.DietCategory;

import com.hnevc.yourhealthmanager.dao.DietCategoryMapper;

import com.hnevc.yourhealthmanager.entity.DietRecord;
import com.hnevc.yourhealthmanager.service.DietCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DietCategoryServiceImpl  extends ServiceImpl<DietCategoryMapper, DietCategory> implements DietCategoryService {
    @Autowired
    private  DietCategoryMapper dietCategoryMapper;

    public DietCategoryServiceImpl(DietCategoryMapper dietCategoryMapper) {
        this.dietCategoryMapper = dietCategoryMapper;
    }

    @Override
    public DietCategory updatePic(Integer id, String filePath) {
        DietCategory dietCategory= dietCategoryMapper.selectById(id);
        dietCategory.setDietCategoryImage(filePath);
        if(dietCategoryMapper.updateById(dietCategory)>0){
            return dietCategory;
        }else{
            return null;
        }
    }
}
